#ifndef NR_PERMISSION_H
#define NR_PERMISSION_H

#include "nr_std.h"

/**
 * @file nr_permission.h
 * 
 * @brief nr_permission_item describe the permission details
 * nr_permissionable is the base class for those who want to
 * support permission setting
 */
 
/**
 * This class describe the permission details
 */
class nr_permission
{
public:
    /**
     * Default constructor
     */
    nr_permission() {}

    /**
     * Destructor
     */
    ~nr_permission() {}
    
    /**
     * Get or set the permission id, but application should not
     * change the id after initialized
     *
     * @return The permission ID reference
     */
    nr_id_t& id() { return m_id; }

    /**
     * Get or set the permission name
     *
     * @return The permission name reference
     */
    QString& name() { return m_name; }
    
    /**
     * Get or set the permission value, use the value to check
     * whether the user have the permission
     *
     * @return The permission value object
     */
    QVariant& value() { return m_value; }

private:
    nr_id_t m_id;
    QString m_name;
    QVariant m_value;
};

/**
 * This permission list
 */
typedef QHash<nr_id_t, nr_permission*> nr_permission_items;

/**
 * This base class for those who want to support permission setting
 *
 * It contains a permission list
 */
class nr_permissionable
{
public:
    /**
     * Default constructor
     */
    nr_permissionable(void);
    
    /**
     * Destructor
     */
    ~nr_permissionable(void);
    
    /**
     * Get the permission list
     *
     * @return The permission list reference, 
     * add or remove permission directly
     */
    nr_permission_items& permissions() { return m_permissions; }
    
private:
    nr_permission_items m_permissions;
};

#endif